package com.xyb.service;

import com.xyb.dao.CourseDao;
import com.xyb.dao.CourseTopicDao;
import com.xyb.entity.Course;
import com.xyb.entity.CourseTopic;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class WebTopicService {
    @Resource
    private CourseTopicDao courseTopicDao;
    @Resource
    private CourseDao courseDao;

    public List<CourseTopic> selectTopicList() {
        List<CourseTopic> list = courseTopicDao.selectCourseTopicListByStatus(1);
        /*for (int i = 0; i < list.size(); i++) {
            if(list.get(i).getTopicId().longValue()==0L){
                list.remove(i);
                break;
            }
        }*/
        return list;
    }

    public CourseTopic selectCourseTopicByTopicId(Long topicId) {
        CourseTopic courseTopic = courseTopicDao.selectCourseTopicByTopicId(topicId);
        return courseTopic;
    }

    public List<Course> selectCourseListByTopicId(Long topicId) {
        //List<Course> list = courseDao.selectCourseByTopicId(topicId);
        List<Course> list = courseDao.selectIsUseCourseByTopicId(topicId);
        return list;
    }
}
